﻿using SW.Lite.IDAL;
using SW.Lite.Infrastructure.Common;
using SW.Lite.Infrastructure.Service;
using SW.Lite.Model;

namespace SW.Lite.BLL
{
    public class Field
    {
        private static readonly IField Dal = ServiceLocator.Instance.GetInstance<IField>("Field");

        /// <summary>
        ///     数据是否存在
        /// </summary>
        /// <param name="id">ID</param>
        public static bool Exists(int id)
        {
            return Dal.Exists(id);
        }

        /// <summary>
        ///     获取单个项
        /// </summary>
        /// <param name="id">ID</param>
        public static FieldModel Single(int id)
        {
            return Dal.Single(id);
        }

        /// <summary>
        ///     获取所有项目
        /// </summary>
        public static PageList<FieldModel> All()
        {
            return Dal.All();
        }

        /// <summary>
        ///     获取所有项目(分页)
        /// </summary>
        public static PageList<FieldModel> All(int pageIndex, int pageSize)
        {
            return Dal.All(pageIndex, pageSize);
        }

        /// <summary>
        ///     插入数据
        /// </summary>
        /// <param name="model">单个项</param>
        public static ExecuteResult Insert(FieldModel model)
        {
            return Dal.Insert(model);
        }

        /// <summary>
        ///     更新数据
        /// </summary>
        /// <param name="model">单个项</param>
        public static ExecuteResult Update(FieldModel model)
        {
            return Dal.Update(model);
        }

        /// <summary>
        ///     删除数据
        /// </summary>
        /// <param name="id">ID</param>
        public static ExecuteResult Delete(int id)
        {
            return Dal.Delete(id);
        }
    }
}